package top.wherewego.vnt.activity;

import androidx.core.content.ContextCompat;

import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.kongzue.baseframework.BaseBindingActivity;
import com.kongzue.baseframework.interfaces.DarkStatusBarTheme;
import com.kongzue.baseframework.util.FragmentChangeUtil;
import com.kongzue.baseframework.util.JumpParameter;

import top.wherewego.vnt.APP;
import top.wherewego.vnt.R;
import top.wherewego.vnt.databinding.ActivityMainBinding;
import top.wherewego.vnt.fragment.AboutFragment;
import top.wherewego.vnt.fragment.ConfigListFragment;
import top.wherewego.vnt.fragment.HelpFragment;
import top.wherewego.vnt.fragment.HomeFragment;

@DarkStatusBarTheme(true)
public class MainActivity extends BaseBindingActivity<ActivityMainBinding> {

    private HomeFragment homeFragment;
    private ConfigListFragment configListFragment;
    private AboutFragment aboutFragment;
    private HelpFragment helpFragment;

    @Override
    public void initViews() {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(this, R.color.white));
        homeFragment = new HomeFragment();
        configListFragment=new ConfigListFragment();
        aboutFragment=new AboutFragment();
        helpFragment = new HelpFragment();
        FragmentChangeUtil util = new FragmentChangeUtil(me, R.id.main_fragment_layout);
        util.addFragment(homeFragment,true);
        util.addFragment(configListFragment,true);
        util.addFragment(aboutFragment,true);
        util.addFragment(helpFragment,true);
        util.show(0);

        binding.mainHome.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                util.show(0);
                binding.mainDrawer.close();
            }
        });
        binding.mainConList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                util.show(1);
                binding.mainDrawer.close();
            }
        });
        binding.mainHelp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                util.show(2);
                binding.mainDrawer.close();
            }
        });
        binding.mainAbout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                util.show(3);
                binding.mainDrawer.close();
            }
        });

        //左侧滑
        binding.mainMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                binding.mainDrawer.openDrawer(Gravity.LEFT);
            }
        });
        //添加配置
        binding.mainAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                jump(AddActivity.class);
            }
        });
    }

    @Override
    public void initDatas(JumpParameter parameter) {
        APP.getConfList();
    }

    @Override
    public void setEvents() {

    }
}